import request from '@/config/axios'
import type { MemberCard } from './types'

export const getMemberCardsListApi = (params: any): Promise<IResponse> => {
  return request.get({ url: '/member-cards', params })
}

export const createMemberCardsApi = (data: Partial<MemberCard>): Promise<IResponse> => {
  return request.post({ url: '/member-cards', data })
}

export const updateMemberCardsApi = (id: string, data: Partial<MemberCard>): Promise<IResponse> => {
  return request.put({ url: `/member-cards/id/${id}`, data })
}

export const getMemberCardsDetailApi = (id: string): Promise<IResponse<MemberCard>> => {
  return request.get({ url: `/member-cards/id/${id}` })
}

export const getMemberCardsDetailByUIDApi = (uid: string): Promise<IResponse<MemberCard>> => {
  return request.get({ url: `/member-cards/uid/${uid}` })
}

export const getMemberCardsDetailByMemberNumberApi = (
  member_number: string
): Promise<IResponse<MemberCard>> => {
  return request.get({ url: `/member-cards/member-number/${member_number}` })
}

export const delMemberCardsListApi = (ids: string[] | number[]): Promise<IResponse> => {
  return request.delete({ url: `/member-cards/id/${ids[0]}` })
}

export const updateMemberCardStatusApi = (
  id: string,
  status: string,
  data: any
): Promise<IResponse> => {
  return request.post({ url: `/member-cards/id/${id}/status/${status}`, data })
}

export const updateTransactionPasswordApi = (id: string, data: any): Promise<IResponse> => {
  return request.post({ url: `/member-cards/id/${id}/transaction-password/update`, data })
}

export const resetTransactionPasswordApi = (id: string, data: any): Promise<IResponse> => {
  return request.post({ url: `/member-cards/id/${id}/transaction-password/reset`, data })
}

export const changeCardApi = (id: string, data: any): Promise<IResponse> => {
  return request.post({ url: `/member-cards/id/${id}/change-card`, data })
}
export const changeSalerApi = (id: string, data: any): Promise<IResponse> => {
  return request.post({ url: `/member-cards/id/${id}/change-saler`, data })
}
